package model

// Category 类别表
type Category struct {
	BaseModel
	Name             string     `gorm:"type:varchar(20);not null;comment:商品类别名称" json:"name"`
	ParentCategoryID int32      `gorm:"comment:父类别ID" json:"parent_category_id"`
	ParentCategory   *Category  `json:"-"`
	SubCategory      []Category `gorm:"foreignKey:ParentCategoryID;references:ID;comment:子类别" json:"sub_category"`
	Level            int32      `gorm:"type:int;not null;default:1;comment:该类别的标题级别" json:"level"`
	IsTab            bool       `gorm:"not null;default:false;comment:是否在表格中显示" json:"is_tab"`
}

// Brands 品牌表
type Brands struct {
	BaseModel
	Name string `gorm:"type:varchar(20);not null;comment:品牌名称" json:"name"`
	Logo string `gorm:"type:varchar(200);not null;default:'';comment:品牌的logo(url)" json:"logo"`
}

// GoodsCategoryBrand 商品类别品牌表(多对多)
type GoodsCategoryBrand struct {
	BaseModel
	CategoryID int32 `gorm:"type:int;index:idx_category_brand,unique;comment:商品类别ID" json:"category_id"`
	Category   Category

	BrandsID int32 `gorm:"type:int;index:idx_category_brand,unique;comment:商品品牌ID" json:"brands_id"`
	Brands   Brands
}

// Banner 轮播图表
type Banner struct {
	BaseModel
	Image string `gorm:"type:varchar(200);not null;comment:图片的url" json:"image"`
	Url   string `gorm:"type:varchar(200);not null;comment:商品详情页的url" json:"url"`
	Index int32  `gorm:"type:int;not null;default:1;comment:轮播图的顺序位置" json:"index"`
}

type Goods struct {
	BaseModel

	CategoryID int32 `gorm:"type:int;not null;comment:商品类别ID" json:"category_id"`
	Category   Category
	BrandsID   int32 `gorm:"type:int;not null;comment:商品品牌ID" json:"brands_id"`
	Brands     Brands

	OnSale   bool `gorm:"default:false;not null;comment:是否上架" json:"on_sale"`
	ShipFree bool `gorm:"default:false;not null;comment:是否免运费" json:"ship_free"`
	IsNew    bool `gorm:"default:false;not null;comment:是否新品" json:"is_new"`
	IsHot    bool `gorm:"default:false;not null;comment:是否热卖品" json:"is_hot"`

	Name            string   `gorm:"type:varchar(50);not null;comment:商品名称" json:"name"`
	GoodsSn         string   `gorm:"type:varchar(50);not null;comment:商品的sn码(商家内部的编号)" json:"goods_sn"`
	ClickNum        int32    `gorm:"type:int;not null;default:0;comment:点击商品详情页的次数" json:"click_num"`
	SoldNum         int32    `gorm:"type:int;not null;default:0;comment:销量" json:"sold_num"`
	FavNum          int32    `gorm:"type:int;not null;default:0;comment:收藏数" json:"fav_num"`
	MarketPrice     int32    `gorm:"type:int;not null;comment:划线价格" json:"market_price"`
	ShopPrice       int32    `gorm:"type:int;not null;comment:商品价格" json:"shop_price"`
	GoodsBrief      string   `gorm:"type:varchar(100);not null;comment:商品简介" json:"goods_brief"`
	Images          GormList `gorm:"type:varchar(1000);not null;comment:商品简介图url" json:"images"`
	DescImages      GormList `gorm:"type:varchar(1000);not null;comment:商品详情图url" json:"desc_images"`
	GoodsFrontImage string   `gorm:"type:varchar(200);not null;comment:商品封面图url" json:"goods_front_image"`
}
